package com.vincent.kdp.ui.vip;

import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

import com.vincent.baseapp.base.BaseActivity;
import com.vincent.baseapp.util.DateUtil;
import com.vincent.kdp.R;
import com.vincent.kdp.ui.bean.entity.VipInfo;
import com.vincent.kdp.ui.vip.contract.VipDetailContract;
import com.vincent.kdp.ui.vip.presenter.VipDetailPresenter;

import butterknife.Bind;
import butterknife.OnClick;

public class VipDetailActivity extends BaseActivity<VipDetailContract.View, VipDetailPresenter> implements
        VipDetailContract.View {


    @Bind(R.id.back_img)
    ImageView mBackImg;
    @Bind(R.id.toolbar_center_tv)
    TextView mToolbarCenterTv;
    @Bind(R.id.portrait_img)
    ImageView mPortraitImg;
    @Bind(R.id.name_tv)
    TextView mNameTv;
    @Bind(R.id.id_card_tv)
    TextView mIdCardTv;
    @Bind(R.id.birthday_tv)
    TextView mBirthdayTv;
    @Bind(R.id.phone_tv)
    TextView mPhoneTv;
    @Bind(R.id.scale_now_tv)
    TextView mScaleNowTv;
    @Bind(R.id.total_scale_tv)
    TextView mTotalScaleTv;
    @Bind(R.id.count_tv)
    TextView mCountTv;
    @Bind(R.id.spending_amount_tv)
    TextView mSpendingAmountTv;
    @Bind(R.id.card_style_tv)
    TextView mCardStyleTv;

    @Override
    public int getLayoutResId() {
        return R.layout.activity_vip_detail;
    }

    @Override
    public void initViewData() {
//        presenter.initView(getIntent());
        mToolbarCenterTv.setText("会员信息");
        VipInfo vipInfo = (VipInfo) getIntent().getSerializableExtra("VipInfo");
        refreshVipInfo(vipInfo);
    }

    @Override
    public VipDetailPresenter initPresenter() {
        return new VipDetailPresenter();
    }

    /**
     * 显示Vip详细信息
     *
     * @param vipInfo
     */
    public void refreshVipInfo(VipInfo vipInfo) {
//        Glide.with(context).load(vipInfo.get).placeholder(R.mipmap
//                .ic_commodity_one).into(mPortraitImg);


        mNameTv.setText(vipInfo.getName());
        mIdCardTv.setText(vipInfo.getIDCard());
        mBirthdayTv.setText(DateUtil.date2String(vipInfo.getBirthday(), "yyyy-MM-dd"));
        mPhoneTv.setText(vipInfo.getPhone());
        mScaleNowTv.setText(vipInfo.getPoints() + "");
        mTotalScaleTv.setText(vipInfo.getTotalPoints() + "");
        mCountTv.setText(vipInfo.getTimes() + "");
        mSpendingAmountTv.setText("￥" + vipInfo.getTotalMoney());
        mCardStyleTv.setText(vipInfo.getIsVip() == 1 ? "VIP卡" : "普通卡");
    }

    @OnClick(R.id.back_img)
    public void onClick() {
        actFinish();
    }
}
